Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Clusterrole to allow Korrel8r to view all signal data #517

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

shwetaap
Copy link
Contributor

@shwetaap shwetaap commented Jun 13, 2024

This PR creates the required clusterroles and clusterrolebindingss, so that korrel8r can query all the required resources
Adds additional clusterrolebinding and rolebinding so that korrel8r can connect to Prometheus endpoints and retrieve relevant data.
All of the roles and rolebindings are created within the operator

Copy link

openshift-ci bot commented Jun 13, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@shwetaap shwetaap force-pushed the korrel8r-role branch 4 times, most recently from 6635ab4 to 512006a Compare June 21, 2024 05:02
@shwetaap shwetaap marked this pull request as ready for review June 21, 2024 05:14
@shwetaap shwetaap requested a review from a team as a code owner June 21, 2024 05:14
@shwetaap shwetaap requested review from danielmellado and slashpai and removed request for a team June 21, 2024 05:14
@shwetaap shwetaap changed the title Add Clusterrole to allow Korrel8r to view Logs and Metrics Add Clusterrole to allow Korrel8r to view all signal data Jun 21, 2024
@danielmellado
Copy link
Contributor

/assign @alanconway @jgbernalp @periklis

@@ -373,7 +373,7 @@ func newKorrel8rDeployment(name string, namespace string, info UIPluginInfo) *ap
Labels: componentLabels(name),
},
Spec: corev1.PodSpec{
ServiceAccountName: info.Name + serviceAccountSuffix,
ServiceAccountName: "obo-" + name + serviceAccountSuffix,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you just name the SA obo-korrel8r-sa, you'd need to drop the prefix here

@anpingli
Copy link

anpingli commented Jun 24, 2024

Test using this PR, my korrel8r was deployed under openshift-operator,, but obo-korrel8r-view bind to operators/obo-korrel8r-sa. it should be openshift-operators/obo-korrel8r-sa. After I fix it manually. The korrel8r works.

operator-sdk run bundle quay.io/anli/observability-operator-bundle:0.0.1-dev
--install-mode AllNamespaces --namespace openshift-operators --skip-tls


oc get ClusterRoleBinding obo-korrel8r-view -o json
{
    "apiVersion": "rbac.authorization.k8s.io/v1",
    "kind": "ClusterRoleBinding",
    "metadata": {
        "creationTimestamp": "2024-06-24T08:31:00Z",
        "labels": {
            "app.kubernetes.io/part-of": "observability-operator",
            "olm.managed": "true",
            "olm.owner": "observability-operator.v0.0.1-dev"
        },
        "name": "obo-korrel8r-view",
        "resourceVersion": "251006",
        "uid": "65b72a1a-408c-4584-8862-8ede4e4b7d04"
    },
    "roleRef": {
        "apiGroup": "rbac.authorization.k8s.io",
        "kind": "ClusterRole",
        "name": "obo-korrel8r-view"
    },
    "subjects": [
        {
            "kind": "ServiceAccount",
            "name": "obo-korrel8r-sa",
            "namespace": "operators"
        }
    ]
}

@jan--f
Copy link
Collaborator

jan--f commented Jun 25, 2024

I think we should consider the following points:

  1. If we deploy korrel8r resources that needs certain permissions we should consider adding that to the operator. It doesn't seem like a great user experience to tell a cluster admin to modify/create a resource so that the operator can function properly.
  2. Those permissions should be as minimal as possible while allowing all needed functionality.

So lets pare down the cluster role to what korrel8r needs. Then the role and rolebinding can be created by the controller, making the subject namespace dynamic. Additionally this adds the needed permissions to the operator.
The service account can either stay in the bundle (OLM will add the correct namespace) or also move to be created by the controller.

@shwetaap shwetaap force-pushed the korrel8r-role branch 2 times, most recently from d0c3ff8 to fb64e43 Compare June 28, 2024 05:39
@shwetaap
Copy link
Contributor Author

@jan--f Made changes to the code as suggested. All (cluster)role and (cluster)rolebinding creation has moved to the operator. The controller now creates the clusterrole needed for korrel8r and creates the clusterrolebinding& rolebinding using existing monitoring clusterrrole and role respectively for allowing access to prometheus and alertmanager endpoints via korrle8r

@shwetaap
Copy link
Contributor Author

/retest

Copy link

@periklis periklis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci openshift-ci bot added the lgtm label Jun 28, 2024
Copy link

openshift-ci bot commented Jun 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: periklis, shwetaap

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jgbernalp
Copy link
Contributor

/test ci-index-observability-bundle

@openshift-merge-bot openshift-merge-bot bot merged commit 0d7afff into rhobs:main Jun 28, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants